//tijiao 2
#include<bits/stdc++.h>
using namespace std;
const int N=10060;
int n,m,L,V,t,ans1,ans2,cnt1,cnt2,cnt3,p[N];
struct Node
{
    int d,v,a,t1;
}q[N];
bool cmp(Node a,Node b)
{
    if(a.d>=b.d) return a.d>=b.d;
}
int solve()
{
    ans1=0,ans2=0,cnt1=0,cnt2=0,cnt3=0;
    cin>>n>>m>>L>>V;
    for(int i=1;i<=n;i++)
    {
        cin>>q[i].d>>q[i].v>>q[i].a;
        if(q[i].a==0)
            cnt1++;
        if(q[i].a<0)
            cnt2++;
        else
            cnt3++;
    }
    for(int i=1;i<=m;i++)
        cin>>p[i];
    sort(q+1,q+n+1,cmp);
    if(cnt1==n)
    {
        for(int i=1;i<=n;i++)
        {
            if(q[i].v>V)
                ans1++;
        }
        cout<<ans1<<" ";
        if(ans1!=0)
        {
            cout<<1<<endl;
        }
        else
            cout<<0<<endl;
    }
    else if(cnt3==n)
    {
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=1000;i++)
            {
                if(q[i].v+q[i].a*j>V)
                {
                    ans1++;
                    break;
                }
            }
        }
        cout<<ans1<<" ";
        if(ans1==0)
            cout<<0<<endl;
        else
        {
           cout<<1<<endl;
        }
    }
    else if(cnt2==n)
    {
        for(int i=1;i<=n;i++)
        {
            if(q[i].v>V)
                ans1++;
        }
        cout<<ans1<<" ";
        if(ans1==0)
            cout<<0<<endl;

    }
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.in","w",stdout);
    cin>>t;
    while(t--) solve();
    return 0;
}
